<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 12. 将定时器的开始和停止过程书写在不同的事件函数内部，容易出现用户多次点击出现加速且运动不能停止的情况，请给出解决代码。 -->
    <button type="button" id="button1">开始</button>
    <button type="button" id="button2">暂停</button>
    <script>
        var timer;
        var start = document.getElementById("button1");
        var end = document.getElementById("button2");
        start.onclick = function () {
            clearInterval(timer);
            timer = setInterval(function () {
                console.log("1");
            },1000);    
        }
        end.onclick = function () {
            clearInterval(timer);
        }
    </script>
</body>
</html>